package com.pro01.backend.service;

import com.pro01.backend.mapper.PointLogMapper;
import com.pro01.backend.pojo.PointLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class PointLogService {

    @Autowired
    private PointLogMapper pointLogMapper;

    public void logIncome(Long userId, int points, String description) {
        PointLog log = new PointLog();
        log.setUserId(userId);
        log.setPoints(points);
        log.setChangeType("INCOME");
        log.setSource("LOTTERY");
        log.setDescription(description);
        pointLogMapper.insertPointLog(log);
    }

    // 支出日志（新增）
    public void logExpense(Long userId, int points, String description) {
        PointLog log = new PointLog();
        log.setUserId(userId);
        log.setPoints(points);
        log.setChangeType("EXPENSE"); // 支出
        log.setSource("LOTTERY");
        log.setDescription(description);
        pointLogMapper.insertPointLog(log);
    }
}

